home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / pdcurs21 / portable / scroll.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-30  |  2.0 KB  |  86 lines

  1. #define    CURSES_LIBRARY    1
  2. #ifndef NO_MEMORY_H
  3. #include <memory.h>
  4. #endif
  5. #include <curses.h>
  6. #undef    scroll
  7.  
  8. #ifdef PDCDEBUG
  9. char *rcsid_scroll = "$Header: C:\CURSES\portable\RCS\scroll.c 2.1 1993/06/18 20:19:13 MH Rel MH $";
  10. #endif
  11.  
  12.  
  13.  
  14.  
  15.  
  16. /*man-start*********************************************************************
  17.  
  18.   scroll()    - scroll window
  19.  
  20.   X/Open Description:
  21.      The window is scrolled up one line.  THis involves moving the
  22.      lines in the window data strcture.
  23.  
  24.   PDCurses Description:
  25.      No additional functionality at this time.  Thought it might be
  26.      be nice to provide reverse scrolling, or scrolling 'n' lines
  27.      in a positive (down) or negative (up) direction in a future
  28.      release for the PC platform.
  29.  
  30.   X/Open Return Value:
  31.      The scroll() function returns OK on succes and ERR on error.
  32.  
  33.   PDCurses Errors:
  34.      It is an error to pass a NULL* window.
  35.  
  36.   Portability:
  37.      PDCurses    int scroll( WINDOW* win );
  38.      X/Open Dec '88    int scroll( WINDOW* win );
  39.      SysV Curses    int scroll( WINDOW* win );
  40.      BSD Curses    int scroll( WINDOW* win );
  41.  
  42. **man-end**********************************************************************/
  43.  
  44. int    scroll(WINDOW *win)
  45. {
  46.     register int    i;
  47.     chtype    blank;
  48.  
  49. #ifdef PDCDEBUG
  50.     if (trace_on) PDC_debug("scroll() - called\n");
  51. #endif
  52.  
  53.     if (win == (WINDOW *)NULL)
  54.         return( ERR );
  55.  
  56.     blank = win->_blank | win->_attrs;
  57.  
  58.     /*
  59.      * Check if window scrolls    and cursor in region.
  60.      */
  61.     if ((!win->_scroll) ||
  62.         (win->_cury < win->_tmarg) ||
  63.         (win->_cury > win->_bmarg))
  64.     {
  65.         return( ERR );
  66.     }
  67.  
  68.     for (i = win->_tmarg; (i < win->_bmarg); i++)
  69.     {
  70.         memcpy(win->_y[i],win->_y[i+1],sizeof(chtype)*(win->_maxx)); /* copy contents of line
  71.                              * so sub windows work */
  72.         win->_firstch[i] = 0;
  73.         win->_lastch[i] = win->_maxx - 1;
  74.     }
  75.  
  76.     for (i=0;i<win->_maxx;i++)
  77.         win->_y[win->_bmarg][i] = blank;
  78.  
  79.     if (win->_cury > win->_tmarg)            /* if not on top line */
  80.         win->_cury--;                /* cursor scrolls too */
  81.  
  82.     win->_firstch[win->_bmarg] = 0;
  83.     win->_lastch[win->_bmarg] = win->_maxx - 1;
  84.     return( OK );
  85. }
  86.